package edu.cuit.campus.common;

/**
 * 统一响应模型
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/8/7 15:06
 */
public record Result<T>(int code, T data, String message) {
    public static Result ok(){
        return new Result(ServiceStatus.SUCCESS.getCode(), null, "业务处理成功");
    }

    public static<T> Result ok(T data){
        return new Result(ServiceStatus.SUCCESS.getCode(), data, "业务处理成功");
    }

    public static<T> Result ok(T data, String message){
        return new Result(ServiceStatus.SUCCESS.getCode(), data, message);
    }

    public static Result fail(){
        return new Result(ServiceStatus.FAIL.getCode(), null, null);
    }

    public static<T> Result fail(T data, String message){
        return new Result(ServiceStatus.FAIL.getCode(), data, message);
    }

    public static Result fail(String message){
        return new Result(ServiceStatus.FAIL.getCode(), null, message);
    }
}
